#ifndef USERMANAGE_H
#define USERMANAGE_H

#include <QWidget>
#include "blldataflow.h"
#include "sqlhelper.h"
#include "useradd.h"
#include "usermodifyrole.h"
#include "userresetpw.h"
#include "userdelete.h"
#include "rolemodify.h"
#include "roleadd.h"
#include "roledelete.h"
#include <QPointer>

namespace Ui {
class UserManage;
}

class UserManage : public QWidget
{
    Q_OBJECT

public:
    explicit UserManage(QWidget *parent = nullptr);
    ~UserManage();

signals:
    void showAllUsersSignal();
    void showAllRolesSignal();

private slots:
    void showAllUsersSlot(bool scrollToBottom = false);
    void showAllRolesSlot(bool scrollToBottom = false);

    void on_btnAddUser_clicked();
    void on_btnUserList_clicked();
    void on_btnRoleManage_clicked();
    void on_btnAddRole_clicked();

    void modifyRolePermission();
    void deleteRole();
    void modifyUserRole();
    void resetUserPassword();
    void deleteUser();
    void setUserEnable(bool state);
    void retranslateUiSlot();
    void setWidgetParent();
    void setWidgetVisibleSlot(int permission);

private:
    void initWidget();
    void retranslateTable();

private:
    Ui::UserManage *ui;
    BllDataFlow * bdf;
    SqlHelper * sqlHelper;

    QPointer<UserAdd> userAdd;
    QPointer<UserModifyRole> userModifyRole;
    QPointer<UserResetPW> userResetPw;
    QPointer<UserDelete> userDelete;

    QPointer<RoleAdd> roleAdd;
    QPointer<RoleModify> roleModify;
    QPointer<RoleDelete> roleDelete;

    QPointer<QToolButton> btnModifyRolePermission;
    QPointer<QToolButton> btnDeleteRole;

    QPointer<QToolButton> btnModifyUserRole;
    QPointer<QToolButton> btnResetPw;
    QPointer<QToolButton> btnDeleteUser;

    QPointer<QWidget> widget;
};

#endif // USERMANAGE_H
